package com.tuanzi.loan.web.bean.receipt.product;

import com.tuanzi.loan.business.service.receipt.product.ReceiptProductInfoService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.vo.request.receipt.product.ReceiptProductInfoSearchRequest;
import com.tuanzi.loan.vo.response.receipt.product.ReceiptProductInfoSearchResponse;
import com.tuanzi.loan.web.configuration.JSFListingBean;
import com.tuanzi.loan.web.lazy.receipt.product.ReceiptApproveProductInfoLazyDataModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.faces.bean.ViewScoped;

/**
 * @author Ray 2017/09/21
 */
@Data
@Debug
@Component
@ViewScoped
@EqualsAndHashCode(callSuper = true)
public class ReceiptProductInfoApproveListBean extends JSFListingBean<ReceiptProductInfoSearchRequest, ReceiptProductInfoSearchResponse> {

	private static final long serialVersionUID = 30992312030673477L;

	@Autowired
	private ReceiptProductInfoService receiptProductInfoService;

	@PostConstruct
	private void init() {
		initLazyDataModel();
	}

	public void onReset() {
		initLazyDataModel();
	}

	public void onApprove(String id) {
		addSuccessfullyMessage();
	}

	public void onReject(String id) {
		addSuccessfullyMessage();
	}

	public String onAdd() {
		return redirect("/views/receipt/product/approve/info.xhtml");
	}

	public String onEdit(String id) {
		return redirect("/views/receipt/product/approve/product-approve.xhtml?id=" + id);
	}

	private void initLazyDataModel() {
		$ = new ReceiptProductInfoSearchRequest();
		lazyDataModel = new ReceiptApproveProductInfoLazyDataModel($);
	}

}
